from django.contrib import admin
from core.tools.models import ShortMsg
from core.tools.models import Province
from core.tools.models import City
from core.tools.models import BankCode
from core.tools.models import PublicPrivate
from core.tools.models import QrCodeGroupChat


# from core.tools.models import TasksResult


class TasksResultAdmin(admin.ModelAdmin):
    list_display = ("task_id", "result", "create_time")


class QrCodeGroupChatAdmin(admin.ModelAdmin):
    list_display = ("description",)


class ShortMsgAdmin(admin.ModelAdmin):
    list_display = ("tel", 'code', "num", 'create_time', "update_time")
    list_filter = ("tel",)
    search_fields = ('tel',)


class CityInline(admin.StackedInline):
    model = City
    fk_name = "province"


class ProvinceAdmin(admin.ModelAdmin):
    inlines = [CityInline, ]


class BankCodeAdmin(admin.ModelAdmin):
    list_display = ("name", "code", "sign")


class PublicPrivateAdmin(admin.ModelAdmin):
    list_display = ("channel_key", "company", "func_type", "file_type_desc")

    def file_type_desc(self, model):
        return model.get_file_type_display()

    file_type_desc.short_description = "提供类型"


admin.site.register(QrCodeGroupChat, QrCodeGroupChatAdmin)
admin.site.register(PublicPrivate, PublicPrivateAdmin)
admin.site.register(ShortMsg, ShortMsgAdmin)
admin.site.register(Province, ProvinceAdmin)
admin.site.register(BankCode, BankCodeAdmin)
# admin.site.register(TasksResult, TasksResultAdmin)
